<template>
<view>
<view class="set-mes">          
        <view class="invoice-remarks justify-content" :style="'display:' + (invoiceToggle?'none':'flex')">
            <view class>提货人 : </view>         
            <input type="text" name="name" :value="name" @input="inputName" placeholder="请输入提货人"></input>               
        </view>    
        <view class="invoice-remarks justify-content" :style="'display:' + (invoiceToggles?'none':'flex')">          
            <view class>联系方式 : </view> 
                 <input type="text" name="mobile" maxlength="11" :value="mobile" @input="inputMobile" placeholder="请输入联系方式"></input>        
        </view>                        
    </view>
    <button class="use-btn" @tap="submit">确定</button>
</view>
</template>

<script>
// pages/cart/invoice/invoice.js
var app = getApp();
var request = app.globalData.request;
var common = require("../../../utils/common.js");

export default {
  data() {
    return {
      name: '',
      mobile: '',
      is_set: false
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var datas = JSON.parse(options.datas);
    options.datas && this.setData({
      name: datas.consignee,
      mobile: datas.mobile
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  methods: {
    inputName: function (e) {
      this.setData({
        name: e.detail.value
      });
    },
    inputMobile: function (e) {
      this.setData({
        mobile: e.detail.value
      });
    },
    submit: function () {
      let name = this.name,
          mobile = this.mobile;

      if (!name) {
        app.globalData.showTextWarining('请输入提货人');
        return false;
      }

      if (!app.globalData.validatemobile(mobile)) {
        return;
      }

      let pages = getCurrentPages(); //当前页面

      let prevPage = pages[pages.length - 2]; //上一页面
      //直接给上移页面赋值 

      prevPage.setData({
        is_set: true,
        name: name,
        mobile: mobile
      });
      uni.navigateBack({
        delta: 1
      });
    }
  }
};
</script>
<style>
/* pages/cart/invoice/invoice.wxss */
page{
     background-color: #fff;
}
.set-mes{
    padding: 0 20rpx;
    font-size: 30rpx;
    color: #444;
    height:300px;
}
.set-mes>view{
    display: flex;
    align-items: center;
    height: 92rpx;
    padding:5px;
    margin:15px 0 15px 0;

}
.set-mes input{
    width: 520rpx;
    height: 50rpx;
    line-height: 50rpx;
    border:1px solid #f3f3f3;
    background:none; 
    border:0px;
}
.set-btn{
    display: flex;
    font-size: 24rpx;
}
.arrow-rigth{
    width: 32rpx;
    height: 32rpx; 
}
.invoice-text{
    color:red;font-size:12px;
}
.use-btn{
    height: 80rpx;
    margin-left: 20rpx;
    text-align: center;
    background-color: #ff6a00;
    color: #fff;
    font-size:16px;
}

.invoice-remarks {
    border:1px solid #f3f3f3;
    box-shadow: 2rpx 2rpx 18rpx #ededed; 
}

.invoice-remarks label{
  margin-left: 5rpx;
  display:inline-block;
}

.justify-content{
    justify-content: space-between;
}
</style>